package org.paradise.dms.services.impl;

import java.util.List;

import org.paradise.dms.dao.impl.SystemUserGroupTaskAllocationDAOImpl;
import org.paradise.dms.pojo.SystemUser;
import org.paradise.dms.pojo.SystemUserGroup;
import org.paradise.dms.pojo.SystemUserTask;
import org.paradise.dms.services.SystemUserGroupTaskAllocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.dheaven.framework.dao.DaoException;

/**
 * 
 * Description: Copyright (c) 2008-2009 paraDise sTudio(DT). All Rights
 * Reserved.
 * 
 * @version 1.0 Mar 30, 2009 10:08:18 PM 郑旭（zhengxu2006@gmail.com）created
 */
@Service
public class SystemUserGroupTaskAllocationServiceImpl implements
		SystemUserGroupTaskAllocationService {
	@Autowired
	@Qualifier("systemUserGroupTaskAllocationDAOImpl")
	private SystemUserGroupTaskAllocationDAOImpl systemusergrouptaskallocationdaoimpl;

	public SystemUserGroupTaskAllocationDAOImpl getSystemusergrouptaskallocationdaoimpl() {
		return systemusergrouptaskallocationdaoimpl;
	}

	public void setSystemusergrouptaskallocationdaoimpl(
			SystemUserGroupTaskAllocationDAOImpl systemusergrouptaskallocationdaoimpl) {
		this.systemusergrouptaskallocationdaoimpl = systemusergrouptaskallocationdaoimpl;
	}

	/**
	 * 
	 * Description: 插入任务分配记录
	 * 
	 * @Version1.0 Mar 30, 2009 10:09:11 PM 郑旭（zhengxu2006@gmail.com）创建
	 * @param systemusergroup
	 * @return
	 */
	public boolean insertTasks(SystemUserTask systemusertask) {

		return systemusergrouptaskallocationdaoimpl.addTask(systemusertask);
	}

	/**
	 * 
	 * Description: 显示用户组所有接受到的任务
	 * 
	 * @Version1.0 Apr 1, 2009 4:11:20 PM 郑旭（zhengxu2006@gmail.com）创建
	 * @param systemusergroupvalue
	 * @param systemusergroupid
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List listSystemUserReceivedTask(int userid, int groupid,
			int taskstatusid,int pageSize, int startRow) {
		return systemusergrouptaskallocationdaoimpl.listSystemUserReceivedTask(
				userid, groupid, taskstatusid, pageSize,  startRow);
	}

	/**
	 * 
	 * Description: 查询所有的用户组
	 * 
	 * @Version1.0 Apr 1, 2009 11:32:37 PM 郑旭（zhengxu2006@gmail.com）创建
	 * @return
	 */
	public List<SystemUserGroup> listAllUserGroup(int value) {
		return systemusergrouptaskallocationdaoimpl.listAllUserGroup(value);
	}

	/**
	 * 
	 * Description: 查出所有级别(value)在我所在的用户组之下的所有用户
	 * 
	 * @Version1.0 Apr 2, 2009 3:36:25 PM 郑旭（zhengxu2006@gmail.com）创建
	 * @param systemusergroupid
	 * @param systemusergroupvalue
	 * @return
	 */
	public List<SystemUser> listAllUserBehindValue(int systemusergroupid,
			int systemusergroupvalue) {
		return systemusergrouptaskallocationdaoimpl.listAllUserBehindValue(
				systemusergroupid, systemusergroupvalue);
	}

	/**
	 * 
	 * Description: 通过用户组id查出所有的用户
	 * 
	 * @Version1.0 Apr 2, 2009 9:26:19 PM 郑旭（zhengxu2006@gmail.com）创建
	 * @param systemusergroupid
	 * @return
	 */
	public List<SystemUser> findUserByGroupid(int systemusergroupid) {
		return systemusergrouptaskallocationdaoimpl
				.findUserByGroupid(systemusergroupid);
	}

	/**
	 * 根据发送者的ID查找所有自己已提交的任务 Description:
	 * 
	 * @Version1.0 Apr 4, 2009 6:39:10 PM 郑旭（zhengxu2006@gmail.com）创建
	 * @param systemusertaskassignerid
	 * @return
	 */
	public List<SystemUserTask> listSentTask(int systemusertaskassignerid,
			int pageSize, int startRow) {
		return systemusergrouptaskallocationdaoimpl.listSentTask(
				systemusertaskassignerid, pageSize, startRow);
	}

	/**
	 * 
	 * Description: 查询将要用于修改的任务
	 * 
	 * @Version1.0 Apr 4, 2009 8:42:24 PM 郑旭（zhengxu2006@gmail.com）创建
	 * @param taskid
	 * @return
	 */
	public List<SystemUserTask> selectTaskForUpdate(int taskid) {
		return systemusergrouptaskallocationdaoimpl.selectTaskForUpdate(taskid);
	}

	/**
	 * 
	 * Description: 修改自己发布的任务
	 * 
	 * @Version1.0 Apr 4, 2009 9:55:01 PM 郑旭（zhengxu2006@gmail.com）创建
	 * @param systemusertask
	 */
	public void updateTask(SystemUserTask systemusertask,
			int oldSystemusertaskid) {
		systemusergrouptaskallocationdaoimpl.updateTask(systemusertask,
				oldSystemusertaskid);

	}

	/**
	 * 
	 * Description: 删除一条任务
	 * 
	 * @Version1.0 Apr 7, 2009 4:26:54 PM 郑旭（zhengxu2006@gmail.com）创建
	 * @param oldSystemusertaskid
	 */
	public String deleteTask(int oldSystemusertaskid) {
		return systemusergrouptaskallocationdaoimpl
				.deleteTask(oldSystemusertaskid);
	}

	/**
	 * 
	 * Description: 任务接收者改变任务的状态
	 * 
	 * @Version1.0 Apr 14, 2009 3:39:52 PM 郑旭（zhengxu2006@gmail.com）创建
	 */
	public String changeStatus(String systemuserstatus, int taskstatusid) {
		return systemusergrouptaskallocationdaoimpl.changeStatus(
				systemuserstatus, taskstatusid);
	}

	/**
	 * 
	 * Description: 获得发送的任务数
	 * 
	 * @Version1.0 Apr 18, 2009 11:13:46 PM 郑旭（zhengxu2006@gmail.com）创建
	 * @param systemusertaskassignerid
	 * @return
	 * @throws DaoException
	 */
	public int getRowsForListSentTask(int systemusertaskassignerid)
			throws DaoException {
		return systemusergrouptaskallocationdaoimpl
				.getRowsForListSentTask(systemusertaskassignerid);
	}
/**
 * 
 * Description:查询收到的任务总数 
 * @Version1.0 Apr 19, 2009 12:55:08 AM 郑旭（zhengxu2006@gmail.com）创建
 * @param systemuserid
 * @param taskacceptergroupid
 * @param taskstatusid
 * @return
 */
	public int getRowsForListReicivedTask(final int systemuserid,
			final int taskacceptergroupid, final int taskstatusid) {
		return systemusergrouptaskallocationdaoimpl.getRowsForListReicivedTask(
				systemuserid, taskacceptergroupid, taskstatusid);
	}

}
